﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core.DS
{
    public static partial class statistics
    {
        public static dynamic isReportUploaded(int eid, string username)
        {
            var sql = new Sql.SqlDataContext();
            var e = sql.DSExperiment.FirstOrDefault(row => row.eid == eid);
            if (e == null) return new
              {
                  success = false,
                  msg = "实验不存在"
              };
            if (e.startTime != null)
                if (e.startTime.Value > DateTime.Now) return new
                {
                    success = false,
                    msg = "实验未开始，请在实验开始时间之后提交。"
                };
            var so = sql.DSExperimentSolve.FirstOrDefault(row => row.eid == eid && row.username == username);
            return new
            {
                success = true,
                result = (so != null && so.report)
            };
        }
    }
}
